# To change this template, choose Tools | Templates
# and open the template in the editor.

class Text
  def initialize(text_home_work)
    @text_home_work = text_home_work
  end
  def open(mode)
    @work_file = File.open(@text_home_work, mode)
  end
  def write(text)
    @work_file.write(text)
  end
  def close
    @work_file.close
  end
  def check_answer(answer_lines)
    answer_count = 0
    home_works = @work_file.readlines()
    home_works_join = home_works.join
    answer_lines.each { |answer|
      if (home_works_join.index(answer.chomp) != nil)
        answer_count += 1
      end
    }
    return answer_count
  end
end
